package com.moli.iov.open.web.controller;

import com.moli.iov.alarm.model.po.AlarmInfo;
import com.moli.iov.open.model.vo.req.AlarmInfoVo;
import com.moli.iov.open.service.IAlarmFacadeService;
import com.moli.iov.rest.RestResponse;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 报警业务
 * </p>
 *
 * @author zql
 * @since 2019/9/27 11:06
 */
@Slf4j
@RestController
@RequestMapping("/alarm")
public class AlarmController extends BaseController {

  @Autowired
  private IAlarmFacadeService alarmFacadeService;

  /**
   * 失联车辆报警列表
   * @param alarmInfoVo
   * @return
   */
  @RequestMapping("/listOfflineAlarms")
  public RestResponse<List<AlarmInfo>> listOfflineAlarms(@RequestBody(required = false) AlarmInfoVo alarmInfoVo){
    if(alarmInfoVo == null){
      alarmInfoVo = new AlarmInfoVo();
    }
    assembleUserInfo(alarmInfoVo);
    return alarmFacadeService.listOfflineAlarms(alarmInfoVo);
  }

  /**
   * 里程异变报警列表
   * @param alarmInfoVo
   * @return
   */
  @RequestMapping("/listMileageExAlarms")
  public RestResponse<List<AlarmInfo>> listMileageExAlarms(@RequestBody(required = false) AlarmInfoVo alarmInfoVo){
    if(alarmInfoVo == null){
      alarmInfoVo = new AlarmInfoVo();
    }
    assembleUserInfo(alarmInfoVo);
    return alarmFacadeService.listMileageExAlarms(alarmInfoVo);
  }


  /**
   * 围栏报警
   * @param alarmInfoVo
   * @return
   */
  @RequestMapping("/listFenceAlarms")
  public RestResponse<List<AlarmInfo>> listFenceAlarms(@RequestBody(required = false) AlarmInfoVo alarmInfoVo){
    if(alarmInfoVo == null){
      alarmInfoVo = new AlarmInfoVo();
    }
    assembleUserInfo(alarmInfoVo);
    return alarmFacadeService.listFenceAlarms(alarmInfoVo);
  }
}
